package com.example.administrator.reader.fragment;


import android.os.Bundle;
import android.support.annotation.Nullable;
import android.support.v4.app.Fragment;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.FrameLayout;

import com.example.administrator.reader.utils.BitmapHelper;
import com.example.administrator.reader.utils.UIUtils;
import com.example.administrator.reader.utils.ViewUtils;
import com.lidroid.xutils.BitmapUtils;


/**
 * Created by Administrator on 2016-09-04.
 */
public abstract class BaseFragment extends Fragment {
    public FrameLayout fl;
    public View view;
    public BitmapUtils bitmapUtils;

    @Nullable
    @Override
    public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
        bitmapUtils = BitmapHelper.getBitmapUtils();
        if (fl == null) {
            fl = new FrameLayout(UIUtils.getContext());
            // 初始化每个Fragment的view
            setUpContentView();
            setUpView();
            setUpData(savedInstanceState);
            fl.addView(view);
        } else {
            ViewUtils.remove(fl);
        }
        return fl;
    }
    protected abstract void setUpContentView();

    protected abstract void setUpView();

    protected abstract void setUpData(Bundle savedInstanceState);


    public abstract void loadData();

    public abstract void reloadData();
}
